<?php 
require_once 'sesi_login.php';
require_once 'konfigurasi.php';
fungsi('umum');

define('PAGE', 'Pemberitahuan');
define('PAGE_ICO', 'icon-circle-exclamation-mark');
define('PAGE_URL', 'pemberitahuan.php');
define('SUBPAGE', 'Detail Perkara');	
koneksi_buka();
panggil_header();
?>

<!-- Content Area -->
<div id="da-content-area">
<div class="row-fluid">

<div class="span12">
	<div class="da-panel collapsible">
		<div class="da-panel-header">
			<span class="da-panel-title">
				<i class="icon-circle-exclamation-mark"></i> Pemberitahuan
			</span>
		</div>
		<div class="da-panel-content da-table-container">
			<table id="da-ex-datatable-numberpaging" class="da-table">
				<thead>
					<tr>
						<th width="120">Tanggal</th>
						<th>Pemberitahuan</th>
					</tr>
				</thead>
				<tbody>
					<?php
						if(LEVEL=="superadmin" || LEVEL=="admin") {
							$q = mysql_query("SELECT * FROM t_pemberitahuan WHERE terbaca='t' and isnull(kd_pegawai) order by waktu desc");
						}if(ID_PEGAWAI==""){
							$q = mysql_query("SELECT * FROM t_pemberitahuan WHERE terbaca='t' AND kd_pengguna='".ID."' order by waktu desc");
						} else {
							$q = mysql_query("SELECT * FROM t_pemberitahuan WHERE terbaca='t' AND kd_pegawai='".ID_PEGAWAI."' order by waktu desc");
						}							
						//$data = mysql_fetch_array(mysql_query("SELECT * FROM t_spdp WHERE kd_perkara='".$kd."'"));						
						while($dt = mysql_fetch_array($q)) {
							$isi = explode('=>',$dt['pemberitahuan']);
												?>
					<tr>
						<td><?php echo $dt['waktu']; ?></td>
						<td><?php 
								if(ID_PEGAWAI==""){
									$href = "perkara.detail.php?kd=".$isi[1]; 
									if($dt['posisi']!=null){
										$href = $href."&p=".$dt['posisi'];
									}
							?>
							<a href="modul/pemberitahuan/pemberitahuan_redirect.php?id=<?php echo $dt['kd_pemberitahuan']?>&url=<?php echo $href;?>">							

							<?php
									if(count($isi)>1){
										echo $isi[0]." dengan kode perkara ".$isi[1];
									}else{
										echo $dt['pemberitahuan'];
									}
							
								}else{
									$href = "perkara.detail.php?kd=".$isi[1]; 
									
							?>
							<a href="modul/pemberitahuan/pemberitahuan_redirect.php?id=<?php echo $dt['kd_pemberitahuan']?>&url=<?php echo $href;?>">							
							<?php
									
									echo $isi[0]." No. Perkara : ".$isi[1];
								} 
							?>
							</a>
						</td>

					</tr>
					<?php } ?>
				</tbody>
			</table>
		</div>
	</div>
</div>

</div>
</div>

<div id="pesan-dialog-div" style="display:none;">
	<p id="berkas"></p>
</div>


<?php
panggil_footer();
koneksi_tutup();
?>
